home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94c.txt / 000015_icon-group-sender _Sat Dec 17 15:33:01 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sun, 18 Dec 1994 04:49:38 MST
  2. To: icon-group-l@cs.arizona.edu
  3. Date: 17 Dec 1994 15:33:01 GMT
  4. From: ruiter@ruls41.fsw.LeidenUniv.nl (Jan-Peter de Ruiter)
  5. Message-Id: <3cv0bd$gdv@highway.LeidenUniv.nl>
  6. Organization: Leiden University, The Netherlands
  7. Sender: icon-group-request@cs.arizona.edu
  8. References: <dkuhlmanD0wuqE.I5w@netcom.com>
  9. Subject: Re: Backtracking in Icon
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. G. David Kuhlman (dkuhlman@netcom.com) wrote:
  13. : But now, in spite of the fact that I have a language
  14. : with a strong backtracking mechanism, I find that I
  15. : don't use it much, except of course, for trivial
  16. : constructs like:
  17.  
  18. :     (checkValid(x) | write("error"))
  19.  
  20. I must admit that in the thousands of Icon programs that I've
  21. written, I've used serious backtracking only once. But when I used it,
  22. it turned out to be very handy. I had this large lexicon of
  23. nouns, and had to devise 4tuples of word pairs like this:
  24.  
  25. toilet paper
  26. paper cloth
  27. cloth builder
  28. builder toilet
  29.  
  30. (NOTE: this is a nonsense example, only for illustration - in Dutch you
  31. have compounds, that look like "toiletpaper", and then it makes
  32. more sense to look for these 4tuples for not all compounds exist
  33. in the Dutch lexicon)
  34.  
  35. I could just write a statement with &'s specifying the
  36. relations I needed, and generate them all using backtracking.
  37. Very nice indeed!
  38.  
  39. There's one more thing I'd like to point out, and that is that
  40. the construct you used as an example can also be programmed in
  41. C. If you just write
  42.  
  43.   (checkValid(x) || printf("error"));
  44.  
  45. you'll have the same thing. So it isn't really backtracking
  46. here. It's actually "short circuit evaluation". The same thing
  47. can be done in LISP or SCHEME, without backtracking.
  48.  
  49. What _can't_ be done in C, and is very convenient in Icon, is
  50.  
  51.     nlines :=  +argument[1] | 10  
  52.  
  53. thereby establishing a default value for nlines that can be 
  54. overwritten by a commandline argument. This is a very natural
  55. formulation that I use very often in my Icon programs.
  56.  
  57. Hoping to have been informative,
  58.  
  59. Jan